<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html; charset=utf-8" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>购物车</title>
	<base href="http://localhost:8081/">
	<link type="text/css" rel="stylesheet" href="static/css/style.css">
	<script language="JavaScript" type="text/javascript" src="static/js/cart.js"></script>
</head>
<body>
	
	<div id="header">
			<img class="logo_img" alt="" src="static/img/logo.gif"/>
			<span class="wel_word">购物车</span>
			<div>
				<span>欢迎<span class="um_span">${user.uname}</span>光临尚硅谷书城</span>
				<a href="order.action?oper=getOrderList">我的订单</a>
				<a href="index.jsp">注销</a>&nbsp;&nbsp;
				<a href="index.jsp">返回</a>
			</div>
	</div>
	
	<div id="main" class="box_order">
		<table>
			<tr>
				<td><input type="checkbox" id="ckAll"/></td>
				<td>商品名称</td>
				<td>数量</td>
				<td>单价</td>
				<td>金额</td>
				<td>操作</td>
			</tr>
				<c:choose>
					<c:when test="${empty user.cartItemList}">
						<tr><td colspan="6">购物车为空</td></tr>
					</c:when>
					<c:otherwise>
						<c:set var="total" value="0"/>
						<c:set var="sum" value="0"/>
						<c:forEach items="${user.cartItemList}" var="cartItem">
							<tr>
								<td><input type="checkbox"name="cid" value="${cartItem.id}"></td>
								<td>${cartItem.book.bname}</td>
								<td>${cartItem.bcount}</td>
								<td><fmt:formatNumber value="${cartItem.bprice}" pattern="#####.##"/> </td>
								<td><fmt:formatNumber value="${cartItem.bcount*cartItem.bprice}" pattern="#####.##"/></td>
								<td><a href="#">删除</a></td>
							</tr>
							<c:set var="total" value="${total + cartItem.bcount}"/>
							<c:set var="sum" value="${sum + cartItem.bcount*cartItem.bprice}"/>
						</c:forEach>
					</c:otherwise>
				</c:choose>
		</table>
		<div class="cart_info">
			<span class="cart_span">购物车中共有<span class="b_count">${fn:length(user.cartItemList)}</span>件商品</span>
			<span class="cart_span">总金额<span class="b_price"><fmt:formatNumber value="${sum}" pattern="####.##"/> </span>元</span>
			<span class="cart_span"><a href="#">清空购物车</a></span>
			<span class="cart_span"><a href="#">继续购物</a></span>
			<span class="cart_span"><a href="javascript:checkout()">去结账</a></span>
		</div>
	
	</div>
	
	<div id="bottom">
		<span>
			尚硅谷书城.Copyright &copy;2015
		</span>
	</div>
</body>
</html>